package cn.itcast.source;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * @author KTL
 * @version V1.0
 * @Package cn.itcast.source
 * @date 2021/2/23 0023 11:00
 * @Copyright © 2015-04-29  One for each, and two for each
 *             演示：DataStream-Source 基于集合的操作
 */
public class SourceDemo01_Collection {
    public static void main(String[] args) throws Exception {
        //TODO 1、source
         StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);
         DataStreamSource<String> df1 = env.fromElements("itcast word");
         DataStreamSource<Object> df2 = env.fromCollection(Arrays.asList("test"));
         DataStreamSource<Long> df3 = env.generateSequence(1, 100);
         DataStreamSource<Long> df4 = env.fromSequence(1, 200);
        //TODO 2、transformation
        //TODO 3、sink
        df1.print();
        df2.print();
        df3.print();
        df4.print();
        //TODO 4、execute
        env.execute();
    }

}
